class Struct:
    def __init__(self, **entries):
        self.__dict__.update(entries)

class __Rank(object):
  lookup_map = {}
  def __init__(self, name, string_name, value):
    self.name = name
    self.string_name = string_name
    self.value = value
    self.lookup_map[string_name] = self

  def __eq__(self, other):
    return self.value == other.value

  def __cmp__(self, other):
    return self.value - other.value

  def __str__(self, *args, **kwargs):
    return self.string_name

class __Suit(object):
  lookup_map = {}
  def __init__(self, name):
    self.name = name
    self.lookup_map[name] = self

  def __eq__(self, other):
    return self.name == other.name

  def __cmp__(self, other):
    return 0 if self == other else -1

  def __str__(self, *args, **kwargs):
    return self.name

King = __Rank('king', 'king', 13)
Queen = __Rank('queen', 'queen', 12)
Jack = __Rank('jack', 'jack', 11)
Ace = __Rank('ace', 'ace', 14)
Ten = __Rank('10', 'ten', 10)
Nine = __Rank('9', 'nine', 9)
Eight = __Rank('8', 'eight', 8)
Seven = __Rank('7', 'seven', 7)
Six = __Rank('6', 'six', 6)
Five = __Rank('5', 'five', 5)
Four = __Rank('4', 'four', 4)
Three = __Rank('3', 'three', 3)
Two = __Rank('2', 'two', 2)

Spades = __Suit('spades')
Hearts = __Suit('hearts')
Diamonds = __Suit('diamonds')
Clubs = __Suit('clubs')

Suits = (Clubs, Spades, Hearts, Diamonds)
Ranks = (Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace)

class __Card(object):
  def __init__(self, rank, suit):
    self.rank = rank
    self.suit = suit

  def __str__(self, *args, **kwargs):
    return '%s of %s' % (self.rank, self.suit,)

  def fileFormat(self):
    return '%s_of_%s' % (self.rank.name, self.suit,)

  def __eq__(self, other):
    return self.rank == other.rank and self.suit == other.suit

  def __cmp__(self, other):
    return 0 if self == other else -1

__Deck = {}

for suit in Suits:
  for rank in Ranks:
    card = __Card(rank, suit)
    __Deck[card.fileFormat()] = card

Cards = Struct(**__Deck)

def Deck():
  return __Deck.values()

import re
import urllib2
if __name__ == '__main__':
  print Cards.ace_of_spades.suit != Cards.king_of_spades.suit

